#include <iostream>
#include <vector>
using namespace std;
class Solution {
 public:
  vector<int> path;
  vector<vector<int>> ans;
  vector<vector<int>> subsets(vector<int>& nums) {
    int len = nums.size();
    backtracking(nums, 0, len);
    return ans;
  }
  void backtracking(vector<int>& nums, int begin, int len) {
    ans.push_back(path);  // 收集分支节点
    if (len == path.size()) {
      return;
    }
    for (int i = begin; i < len; i++) {  //  begin为搜索起点
      path.push_back(nums[i]);
      backtracking(nums, i + 1, len);  // i+1，节点不可重复使用
      path.pop_back();
    }
  }
};